import java.util.Random;
import java.util.Scanner;
public class Game {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Random random=new Random();
        int guess=random.nextInt(100);//获取1到100随机数
        while(true)//输入到猜对为止 使用死循环
        {
            System.out.println("请猜一个1到100的数字：");
            int number=sc.nextInt();
            if(number>guess)
            {
                System.out.println("猜大了！");
            }
            else if(number<guess)
            {
                System.out.println("猜小了！");
            }
            else if(number==guess)
            {
                System.out.println("猜对了！");
                sc.close();//关闭键盘输入
                return;//猜对退出程序
            }
            else {
                System.out.println("输入有误！");
            }

        }

    }
}
